<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="" name="myform">
请输入字符：<input id=1 type="text"  onclick="action1()" Onblur="action2()"><p id="comment1" style="display:none;">请输入长度小于15的字符串</p><p id="warm1" style="display:none;color: red">字符串长度不能大于15个</p><br>
请输入邮箱：<input id=2 type="text"  onclick="action3()" Onblur="action4()"><p id="comment2" style="display:none;">请输入邮箱账号</p><p id="warm2" style="display:none;color: red">邮箱格式输入错误</p><br>
男：<input name="sex" type="radio" value="男">&nbsp;&nbsp;&nbsp;
女：<input name="sex" type="radio" value="女"><br>
<h4>兴趣爱好</h4><br>
<table>
<tr>
<th>羽毛球</th>
<th><input name="hobby" type="checkbox" value="羽毛球"></th>
<th>乒乓球</th>
<th><input name="hobby" type="checkbox" value="乒乓球"></th>
<th>橄榄球</th>
<th><input name="hobby" type="checkbox" value="橄榄球"></th>
<th>曲棍球</th>
<th><input name="hobby" type="checkbox" value="曲棍球"></th>
</tr>
</table>
<input type="submit" value="提交">


</form>
<script type="text/javascript">
function action1(){	
	document.getElementById("warm1").style.display="none";
	document.getElementById("comment1").style.display="inline";	
	}
function action2(){
	if(document.getElementById(1).value.length>15){
		document.getElementById("comment1").style.display="none";
		document.getElementById("warm1").style.display="inline";
	}else{
		document.getElementById("comment1").style.display="none";		
	}	
}
function action3(){	
	document.getElementById("warm2").style.display="none";
	document.getElementById("comment2").style.display="inline";	
	}
function action4(){
	var num1=document.getElementById(2).value.indexOf("@");
	var num2=document.getElementById(2).value.lastIndexOf(".");
	var num3=document.getElementById(2).value.slice(num2+1);
	//alert(num3);
	if(num1<1||num2-num1<2||(num3!="com"&&num3!="cn"&&num3!="net")){
		document.getElementById("comment2").style.display="none";
		document.getElementById("warm2").style.display="inline";
	}else{
		document.getElementById("comment2").style.display="none";
	}
	
	}
</script>
</body>
</html>